package stark.app.function.gobang;

import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.stark.gobang.lib.view.AiChessView;

import stark.app.R;
import stark.app.databinding.FragmentGoBangAiDemoBinding;
import stark.common.basic.base.BaseNoModelFragment;

public class GoBangAiDemoFragment extends BaseNoModelFragment<FragmentGoBangAiDemoBinding> {
    @Override
    protected int onCreate() {
        return R.layout.fragment_go_bang_ai_demo;
    }

    @Override
    protected void initView() {
        mDataBinding.btAiBattleRegret.setOnClickListener(this);
        mDataBinding.btAiBattleAgain.setOnClickListener(this);
        mDataBinding.btAiBattleStartBlack.setOnClickListener(this);
        mDataBinding.btAiBattleStartWhite.setOnClickListener(this);

        mDataBinding.aiChessView.setListener(new AiChessView.IListener() {
            @Override
            public void onClickWin() {
                ToastUtils.showShort("赢了");
            }

            @Override
            public void onClickDefeat() {
                ToastUtils.showShort("输了");
            }

            @Override
            public void onClickDraw() {
                ToastUtils.showShort("和棋");
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.btAiBattleRegret) {
            mDataBinding.aiChessView.regret();
        } else if (id == R.id.btAiBattleAgain) {
            mDataBinding.aiChessView.clear();
        } else if (id == R.id.btAiBattleStartBlack) {
            mDataBinding.aiChessView.startBlack();
        } else if (id == R.id.btAiBattleStartWhite) {
            mDataBinding.aiChessView.startWhite();
        }
    }
}
